/*
 * @Author: LiJia
 * @Date: 2021-02-27 10:29:32
 * @LastEditTime: 2021-02-27 13:09:27
 * @LastEditors: LiJia
 * @Description: Description
 * @FilePath: \test\src\modules\account\login.ts
 */

import express from "express"

const router = express.Router()

class LoginClass {
  username!: string
  password!: string
  
  getUsername() {
    return this.username
  }
  getPassword() {
    return this.password
  }
}

router.post('/login', (req, res, _next) => {
  // console.log(req.body)
  const params = req.body
  let response = {}
  let loginCls = new LoginClass()
  
  loginCls.username = params.username
  loginCls.password = params.password

  if (loginCls.getUsername() === '李家' && loginCls.getPassword() === '123') {
    response = {
      code: "ok",
      data: [],
      message: "登录成功"
    }
  } else {
    response = {
      code: "error",
      data: [],
      message: "登录失败"
    }
  }

  res.json(response)
})

export default router
